import React from 'react';
import Cookies from 'js-cookie';

interface UserHead {
  userId: number;
  size: number;
}

export const getUserHeadURL = (userId: number) => {
  const token = Cookies.get('token');
  const r = Math.random();
  const flag = new Date().getTime();
  return `/ImageType/GetUserAvatar?token=${token}&userId=${userId}&flag=${flag}&r=${r}`
}

const UserHead: React.FC<UserHead> = (props) => {
  return (
    <img
      style={{
        width: props.size,
        height: props.size,
      }}
      src={getUserHeadURL(props.userId)} alt="" />
  )
}

export default UserHead;